home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Game-Power
/
Amiga Game-Power.iso
/
anwendungen
/
gw print
/
bcpl
/
process.doc
< prev
next >
Wrap
Text File
|
1994-05-20
|
3KB
|
56 lines
PROCESS CREATION
Author: Bill Kinnersley
Date: Mar 12, 1988
Mail: Physics Dept.
Montana State University
Bozeman, MT 59717
BITNET: iphwk@mtsunix1
INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu
UUCP: ...psuvax1!mtsunix1.bitnet!iphwk
There are several ways of creating a process on the Amiga.
At the lowest level is AddTask(task, initialPC, finalPC),
which adds a given task to the TaskReady list. Here task is an existing
initialized Task structure, initialPC is the entry point, and finalPC
is an optional cleanup routine. The final code is pushed on the stack
as if it were the outermost return address. If finalPC is 0, the system
default cleanup is to call RemTask(), which removes the task from the Ready
list. It deallocates the MemEntry list, but not the Task structure. The
task's registers are initially set to 0, except for SP, which is set to
SPReg. The user may reserve space for initial data by specifying
SPReg < SPUpper.
At the next level is createproc(segarray, stkszlw, pri, ^name, ^gv).
(The internal AmigaDOS function, function 84, at ff4586). Both NewCLI and
Run call this function. It:
Allocates memory for Process structure and stack, and puts this
on the MemList
Fills the Task, Process, and DOS MsgPort:
SigWait for signal 8, and default TrapCode = ff4b6a
Reserves stack space to hold the Process name
Copies the parent's Console Handler, File Handler, and Window
AddTask()'s with special initPC and finalPC.
The finalPC code frees the SegArray.
The initPC code:
Fills the stack with "tttu", terminating with -1 and SP;
Sets the BCPL coroutine list to point to SPLower;
Looks at the Segarray. If there is more than one entry, it calls
GetSegList to fill in the GV;
It then fills in a5 and a6, waits for a startup packet, and
then calls the program code at 4(a2).
The external AmigaDOS function CreateProc(*name, pri, seg, stkszb) is
function -48 at ff46bc. In this case only a seglist is supplied, and
thus the call must create its own SegArray.
The name buffer is subtracted from the stack request
20 bytes are AllocMem'ed for the SegArray.
The GV is obtained from DosLib
The Task, Process and MsgPort are initialized as above
The SPReg and ReturnAddr set
The 1st and 2nd SegList are copied from the parent, the 3rd
SegList is the one supplied by caller, but the SegArray
length is set to 2
AddTask() is called, with initPC = 1st SegList, and finalPC the
same as above.
The next level is function 1c0 at ff61e0, which calls either
84 or -48, depending on the flags it is passed. It is called by no one?
1a0 (at ff5328) is an execute call, which calls -54 at ff53b4
(calls 144, at ff717c, loadseg), then 148 at ff7af0, unloadseg.